# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gdk-pixbuf2

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.30.8
pkgrel=1
pkgdesc="An image loading library (mingw-w64)"
arch=('any')
url="http://www.gtk.org"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
        "${MINGW_PACKAGE_PREFIX}-glib2>=2.37.2"
        "${MINGW_PACKAGE_PREFIX}-jasper"
        "${MINGW_PACKAGE_PREFIX}-libpng"
        "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo"
        "${MINGW_PACKAGE_PREFIX}-libtiff")
options=('strip' 'staticlibs')
install=${_realname}-${CARCH}.install
source=("http://download.gnome.org/sources/gdk-pixbuf/${pkgver%.*}/gdk-pixbuf-$pkgver.tar.xz"
        0002-A-hack-to-fix-export-symbols.mingw.patch
        0003-use-free-software-libs-on.mingw.patch
        0004-give-cc-to-gir-scanner.all.patch)
sha256sums=('4853830616113db4435837992c0aebd94cbb993c44dc55063cee7f72a7bef8be'
            '31c64c6f783ca0f48bc6857451bb68da4e132f7857d6462cf16c5971c64d7f57'
            '02c29eae558c0297e59422d2159230d65ba5d781c02f3cd39937e76b24f02369'
            'bce33b7f4b156ef256285381d28bcf910a8437c4fd668d90b25e5901cc1dcff3')

prepare() {
  cd ${srcdir}/gdk-pixbuf-${pkgver}
  patch -p1 -i ${srcdir}/0002-A-hack-to-fix-export-symbols.mingw.patch
  patch -p1 -i ${srcdir}/0003-use-free-software-libs-on.mingw.patch
  patch -p1 -i ${srcdir}/0004-give-cc-to-gir-scanner.all.patch
  
  autoreconf -fi
}

build() {
  CFLAGS+=" -mms-bitfields"
  CXXFLAGS+=" -mms-bitfields"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ${srcdir}/gdk-pixbuf-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --enable-introspection
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
}
